package com.leo.leetcode.s100;

import com.sun.org.apache.xpath.internal.SourceTree;

/**
 *
 * @author xuexiaolei
 * @version 2017年12月01日
 */
public class T70ClimbingStairs {
    public static int climbStairs(int n) {
        if (n<3) return n;
        int pre2 = 1;
        int pre1 = 2;
        int ans = 0;
        for (int i = 3; i <=n ; i++) {
            ans = pre2 + pre1;
            pre2 = pre1;
            pre1 = ans;
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(climbStairs(3));
        System.out.println(climbStairs(4));
    }
}
